package starter.kit.rx.app.feature.film;

import android.content.Context;
import android.content.Intent;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import starter.kit.rx.app.R;
import starter.kit.rx.app.model.bean.top250.Subjects;
import starter.kit.rx.app.util.DisplayImgUtis;
import support.ui.adapters.EasyViewHolder;

/**
 * ============================================================
 * 版权： xx 版权所有（c）2016
 * <p>
 * 作者：Loofer
 * 版本：1.0
 * 创建日期 ：2016/10/25 10:07.
 * 描述：
 * <p>
 * 注:如果您修改了本类请填写以下内容作为记录，如非本人操作劳烦通知，谢谢！！！
 * Modified Date Modify Content:
 * <p>
 * ==========================================================
 */
public class RootViewHolder extends EasyViewHolder<Subjects> {

    @BindView(R.id.tv_rank)
    TextView mTvRank;
    @BindView(R.id.iv_film)
    ImageView mIvFilm;
    @BindView(R.id.tv_film)
    TextView mTvFilm;
    @BindView(R.id.tv_film_english)
    TextView mTvFilmEnglish;
    @BindView(R.id.tv_film_grade)
    TextView mTvFilmGrade;
    @BindView(R.id.ll_item_view)
    LinearLayout mLlItemView;

    private Context mContext;

    public RootViewHolder(Context context, ViewGroup parent) {
        super(context, parent, R.layout.item_film_top_250);
        ButterKnife.bind(this, itemView);
        this.mContext = context;
    }

    @Override
    public void bindTo(int position, Subjects subjects) {
        DisplayImgUtis.getInstance().display(mContext, subjects.getImages().getLarge(), mIvFilm);
        mTvFilm.setText(subjects.getTitle());
        mTvFilmEnglish.setText(subjects.getOriginal_title());
        mTvFilmGrade.setText("评分:" + subjects.getRating().getAverage());
        if (position < 9) {
            mTvRank.setText("0" + (position + 1));
        } else {
            mTvRank.setText("" + (position + 1));
        }
        mLlItemView.setOnClickListener(view -> {
            Intent intent=new Intent(mContext,FilmDetailActivity.class);
            intent.putExtra(FilmDetailActivity.EXTRA_ID,subjects.identifier);
            mContext.startActivity(intent);
        });
    }



}
